package com.example.util;

import com.example.exception.CustomException;
import org.springframework.stereotype.Component;

@Component
public class ExceptionUtil {

    public void assertException(JudgmentLogic judgmentLogic, String errMsg){
        if (judgmentLogic.judgment()){
            throw new CustomException(errMsg);
        }
    }

    public <T> T assertReturn(Class<T> clazz,T obj) throws InstantiationException, IllegalAccessException {
         if (obj==null){
             return clazz.newInstance();
         }else {
             return obj;
         }
    }
}
